<template>
    <div>
        <div style="margin-top: 10%;margin-right: 30%;margin-left: 30%;width:300px">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="发货单号">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="客户信息">
                    <el-select v-model="form.value1" style="width: 220px;">
                      <el-option v-for="item in options1" :key="item.id" :value="item.id" :label="item.clint_name"></el-option>
                    </el-select>
                </el-form-item>            
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">立即添加</el-button>
                </el-form-item>
                </el-form>
        </div>
    </div>
</template>

<script>
import {getclient,add_order} from '../../api/api.js'
export default {
    data() {
      return {
        form: {
          name: '',
          value1: '',   
        },
        options1: [],
      }
    },
    mounted:function(){
      this.all_client()
    },
    methods: {
        //获取所有客户信息
        all_client() {
            var params = {
        };
        getclient(params).then(res=>{
            console.log(res.data)
            this.options1 = res.data
        })
        },
        onSubmit() {
        console.log(this.form.value1,this.form.name);
        var params = {
              order : this.form.name,
              client_id : this.form.value1,
            };
            add_order(params).then(res=>{
              this.$message(res.message)
          })
      }
    }
}
</script>

<style>

</style>